<?php
if(!isset($_SESSION)) 
	{ 
		session_start(); 
	}
//$loadboardhomeVN = mysql_query("select e.UserName,e.IDEmployee, e.FullName,b.* from employee e, board b
	//				where e.IDEmployee = b.IDEmployee and b.Status = 1
	//				 and b.Type='VN' order by b.CreatedDate desc");
//$loadboardhomeKR = mysql_query("select e.UserName,e.IDEmployee, e.FullName,b.* from employee e, board b
//					where e.IDEmployee = b.IDEmployee and b.Status = 1
//					 and b.Type='KR' order by b.CreatedDate desc");
//$loadboardhomeEN = mysql_query("select e.UserName,e.IDEmployee, e.FullName,b.* from employee e, board b
	//				where e.IDEmployee = b.IDEmployee and b.Status = 1
		//			 and ((b.Type='KR') or (b.Type='VN')) order by b.CreatedDate desc");

$loadboardhome = mysql_query("select e.UserName,e.IDEmployee, e.FullName,b.* from employee e, board b
					where e.IDEmployee = b.IDEmployee and b.Status = 1 order by b.CreatedDate desc");

$selectinforemp = mysql_query("SELECT UserName,FullName,Phone,DATE_FORMAT(Birthday,'%Y-%m-%d') as Birthday,Address,Email FROM employee WHERE IDEmployee ='$id_employee'");
$resultempl = mysql_fetch_assoc($selectinforemp);
$fullnamemp = $resultempl[FullName];
$phone = $resultempl[Phone];
$birthday = $resultempl[Birthday];
$address = $resultempl[Address];
$email = $resultempl[Email];
$us = $resultempl[UserName];

include 'substring-comment.php';
?>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="admin/css/jsDatePick_ltr.min.css" rel="stylesheet"
	type="text/css" media="all" />
<script type="text/javascript" src="admin/css/jsDatePick.min.1.3.js"></script>
<script type="text/javascript" src="admin/js/md5.js"></script>
<script type="text/javascript">
function waiting(){
	alert("Update profile successfuly!");
}
function watingPass(){
	alert("Update password successfuly!");
}
function processPreviewNotice(idboard,view,els){
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp.onreadystatechange=function()
	  {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
	    {

	        document.getElementById("contentHome").innerHTML=xmlhttp.responseText;
	        
	    }
	  }
	var lang = '<?=$_SESSION['lang']?>';
	xmlhttp.open("GET","home/view-content-home.php?idboard="+idboard+"&view="+view+"&newlang="+lang,true);
	xmlhttp.send();
}

function onclickbackHome(){
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp.onreadystatechange=function()
	  {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
	    {
	        document.getElementById("contentHome").innerHTML=xmlhttp.responseText;
	    }
	  }
	var lang = '<?=$_SESSION['lang']?>';
	xmlhttp.open("GET","home/backhome.php?newlang="+lang,true);
	xmlhttp.send();

}
function getCalendar(){
	new JsDatePick({
		useMode:2,
		target:"probirthday",

		dateFormat:"%Y-%m-%d"
	});
	
}
window.onload = getCalendar();

function getviewprofile(fullname,phone,email,address,birthday,els){
	popuploadbel(els);
	window.onload = getCalendar();
	document.getElementById("profullname").value=fullname;
	document.getElementById("prophone").value=phone;
	document.getElementById("promail").value=email;
	document.getElementById("proaddress").value=address;
	document.getElementById("probirthday").value=birthday;
}

function updateviewprofile(){
	var fullname=document.getElementById("profullname").value;
	
	var phone=document.getElementById("prophone").value;
	var email=document.getElementById("promail").value;
	var address=document.getElementById("proaddress").value;
	var birthday=document.getElementById("probirthday").value;
	var idemp = document.getElementById("idemployee").value;
	var lang = '<?=$_SESSION['lang']?>';
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp.onreadystatechange=function()
	  {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
	    {
		    //alert(xmlhttp.responseText);
	        document.getElementById("contentHome").innerHTML=xmlhttp.responseText;
	    }
	  }
	
	xmlhttp.open("GET","home/process-update-viewprofile.php?idemployee="+idemp+"&profullname="+fullname+"&prophone="+phone+"&promail="+email+"&proaddress="+address+"&probirthday="+birthday+"&newlang="+lang,true);
	xmlhttp.send();
	
}
function resetpassword(){
	document.getElementById("oldpassword").value="";
	document.getElementById("newpassword").value="";
	document.getElementById("repassword").value="";
}
function validatePassword(){
	var oldpass = document.getElementById("oldpassword").value;
	var newpass = document.getElementById("newpassword").value;
	var repass = document.getElementById("repassword").value;

	var passemp = document.getElementById("hidepass").value;
	var md5oldpass = MD5(oldpass).toUpperCase();

	if(oldpass.length==0){
		alert('<?php echo $l_alertoldpass?>');
		return false;
	}else if(newpass.length==0){
		alert('<?php echo $l_alertnewpass?>');
		return false;
	}else if(repass.length==0){
		alert('<?php echo $l_alertrepass?>');
		return false;
	}else if(newpass != repass){
		alert('<?php echo $l_alertpassandrepass?>');
		return false;
	}else if(md5oldpass != passemp){
		alert("<?php echo $l_oldpassnotcorrect?>");
		return false;
	}else{
		updatePassword();
	}
}

function updatePassword(){
	var oldpass = document.getElementById("oldpassword").value;
	var newpass = document.getElementById("newpassword").value;
	var repass = document.getElementById("repassword").value;

	var idemp = document.getElementById("idempl").value;
	var lang = '<?=$_SESSION['lang']?>';

	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp.onreadystatechange=function()
	  {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
	    {
		    //alert(xmlhttp.responseText);
	        document.getElementById("contentHome").innerHTML=xmlhttp.responseText;
	    }
	  }
	watingPass();
	xmlhttp.open("GET","home/process-update-password.php?idemployee="+idemp+"&newpass="+newpass+"&newlang="+lang,true);
	xmlhttp.send();
}
function onclickChangepass(oldpass, newpass,repass,els){
	popuploadbel(els);
	document.getElementById("oldpassword").value=oldpass;
	document.getElementById("newpassword").value=newpass;
	document.getElementById("repassword").value=repass;
}
</script>
<div id="contains" style="background-color: #f3f3f3;">

	<div class="body" id="contentHome">
		<div class="nav_top" style="width: 100%;">
       		<div class="nav_tit"><?php echo $l_generalnotice;?></div>     
            <div class="rehome"><a href="mainPhone.php"><?php echo $l_menu?></a></div>       
       	</div>
		<div id="board-content" style="padding-top: 20px;">
				<img src="images/line1.png" width="100%" /><br /> <br /> 
			<table width="100%" style="border: 1px dotted silver;background-color: white;">
				<tr>
					<th width="5%"
						style="border-right: 1px dotted silver; border-bottom: 1px dotted silver;"><?php echo $l_no?></th>
					<th width="55%"
						style="border-right: 1px dotted silver; border-bottom: 1px dotted silver;"><?php echo $l_title?></th>
					<th width="17%"
						style="border-right: 1px dotted silver; border-bottom: 1px dotted silver;"><?php echo $l_createdby?></th>
					<th width="15%"
						style="border-right: 1px dotted silver; border-bottom: 1px dotted silver;"><?php echo $l_created_date?></th>
					<th width="8%" style="border-bottom: 1px dotted silver;"><?php echo $l_views?></th>
				</tr>
			
			 <?php $i=0;
					while ($row=mysql_fetch_array($loadboardhome)){
						$i++;
						$idboard = $row[ID];
						$rowtitle = $row[Title];
						$rowtitle = strip_tags($rowtitle);
						?>
				<tr>
					<td
						style="border-right: 1px dotted silver; border-bottom: 1px dotted silver;color: #000000"><?php echo $i?>
					</td>
					<td
						style="border-right: 1px dotted silver; border-bottom: 1px dotted silver; padding-left: 5px;">
						<a href="#" style="color: #0080ff;"  onclick="processPreviewNotice('<?=$idboard?>',<?=$row[View]?>,this);"><?php echo substringProvider::catchuoi($rowtitle,30);?>
					</a><img src="images/ico_new_group.gif" height="11px" width="19px"
						style="margin: 0px 8px" /></td>
					<td
						style="border-right: 1px dotted silver; border-bottom: 1px dotted silver;text-align: left;color: #000000"><?php echo $row[FullName]?>
					</td>
					<td
						style="border-right: 1px dotted silver; border-bottom: 1px dotted silver;color: #000000"><?php echo $row[CreatedDate]?>
					</td>
					<td
						style="border-right: 1px dotted silver; border-bottom: 1px dotted silver;color: #000000"><?php echo $row[View]?>
					</td>
				</tr>
				<?php } ?>
			</table>
			<div class="login_succ" style="padding-top: 10px;">
				<div class="welcome" style="width: 100%;">
					<div class="tit_welcome" style="color: #000000"><?php echo $l_welcome?> <?php echo $us;?></div>
					<!-- 
					<ul style="padding-left: 0px">
						<li><img src="images/user.png" alt="" /><a href="#?w=350" rel="privateInformation" class="poplight"
							onclick="getviewprofile('<?=$fullnamemp?>','<?=$phone?>','<?=$email?>','<?=$address?>','<?=$birthday?>',this);"><?php echo $l_viewprofile?></a>
						</li>
						
						<li><img src="images/change_pass.png" alt="" /><a href="#?w=350" rel="changepassword" class="poplight"
							 onclick="onclickChangepass('','','',this);"><?php echo $l_changepassword?></a>
						</li>
						
						<li><img src="images/logout.png" alt="" /><a href="logout.php"><?php echo $l_logout?></a>
						</li>
						
					</ul>

					<div style="clear: both"></div>
					<div class="line_tit"></div>
					 -->
						<table class="main_page" cellspacing="20px" align="center">
							<tr>
								<td><img src="images/approval.png" alt="" /><a
									href="ApproveMain.php" style="color: #1f1f1f"><?php echo $l_e_approval?></a></td>
								<td><img src="images/project.png" alt="" />
								<a href="ProjectMain.php" style="color: #1f1f1f"><?php echo $l_project?></a>
								</td>
							</tr>
						</table>
				</div>
			</div>
		</div>
	</div>
</div>

<!-- 
<div id="privateInformation" class="popup_block">
	<span
		style="background: #dad6cf; color: #000000; font-weight: bold; display: block; padding: 5px 0 5px 10px;"><?php echo $privateinfor;?>
	</span>
	<form action="" method="get">
		<input type="hidden" id="idemployee" name="idemployee"
			value="<?=$id_employee?>">
		<table width="100%" style="margin: 20px 0">
			<thead>
				<tr>
					<th scope="colgroup" colspan="2"><img src="images/profile.jpg"
						alt="profile" width="80px" /> <br />
					</th>
				</tr>
			</thead>
			<tr>
				<td style="padding-left: 5px"><?php echo $l_fullname?></td>
				<td><input id="profullname" name="profullname" type="text" value="<?=$fullnamemp?>"
					style="width: 230px; height: 22px; font-size: 13px;" /></td>
			</tr>
			<tr>
				<td style="padding-left: 5px"><?php echo $l_phone?></td>
				<td><input id="prophone" name="prophone" type="text" value="<?=$phone?>"
					style="width: 230px; height: 22px; font-size: 13px;" /></td>
			</tr>
			<tr>
				<td style="padding-left: 5px"><?php echo $l_email?></td>
				<td><input id="promail" name="promail" type="text" value="<?=$email?>"
					style="width: 230px; height: 22px; font-size: 13px;" /></td>
			</tr>
			<tr>
				<td style="padding-left: 5px"><?php echo $l_address?></td>
				<td><input id="proaddress" name="proaddress" type="text" value="<?=$address?>"
					style="width: 230px; height: 22px; font-size: 13px;" /></td>
			</tr>
			<tr>
				<td style="padding-left: 5px"><?php echo $l_birthday?></td>
				<td><span style="white-space: nowrap;"> <input class="rf-cal-inp "
						id="probirthday" name="probirthday" readonly="readonly"
						style="vertical-align: middle; width: 230px; height: 22px; font-size: 13px;"
						type="text" value="<?=$birthday?>" /> </span>
				</td>
			</tr>
		</table>
		<div align="right" style="padding: 0px 30px 20px">
			<input type="button" onclick="updateviewprofile();waiting();"
				style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; width: 100px;"
				class="btnupbg btnupload iclose" value="<?php echo $l_update?>" /> <input
				type="button" class="btnupbg btnupload iclose"
				style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; width: 100px;"
				value="<?php echo $l_cancel;?>" />
		</div>
	</form>
</div>

<div id="changepassword" class="popup_block">
	<span
		style="background: #dad6cf; color: #000000; font-weight: bold; display: block; padding: 5px 0 5px 10px;"><?php echo $l_changepassword;?>
	</span>
	<?php $checkpass = mysql_query("Select Password from employee where IDEmployee='$id_employee';");
		$vl = mysql_fetch_assoc($checkpass);?>
	<form action="#">
			<input type="hidden" id="idempl" name="idempl" value="<?=$id_employee?>">
			<input type="hidden" id="hidepass" name="hidepass" value="<?=$vl[Password]?>">
		<table width="100%" style="margin: 20px 0">
			<thead>
				<tr>
					<th scope="colgroup" colspan="2"><img
						src="images/icon_member_resend_pass.gif" alt="profile"
						width="80px" /> <br />
					</th>
				</tr>
			</thead>
			<tr>
				<td style="padding-left: 5px"><?php echo $l_oldpass?></td>
				<td><input id="oldpassword" name="oldpassword" type="password" value=""
					style="width: 215px; height: 22px; font-size: 13px; margin-right: 5px" />
				</td>
			</tr>
			<tr>
				<td style="padding-left: 5px"><?php echo $l_newpassword?></td>
				<td><input id="newpassword" name="newpassword" type="password" value=""
					style="width: 215px; height: 22px; font-size: 13px; margin-right: 5px" />
				</td>
			</tr>
			<tr>
				<td style="padding-left: 5px"><?php echo $l_retypepassword?></td>
				<td><input id="repassword" name="repassword" type="password" value=""
					style="width: 215px; height: 22px; font-size: 13px; margin-right: 5px" />
				</td>
			</tr>

		</table>
		<div align="right" style="padding: 0px 30px 20px">
			<input type="button" onclick="validatePassword();"
				style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; width: 100px;"
				class="btnupbg btnupload iclose" value="<?php echo $l_update?>" /> 
			<input type="button" class="btnupbg btnupload iclose" onclick="resetpassword();"
				style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; width: 100px;"
				value="<?php echo $l_cancel;?>" />
		</div>
	</form>
</div>
 -->